<template>
  <div>
    <div class="loadmore-wrapper" ref="loadmoreWrapper" style="height: 100vh;overflow: scroll">
      <mt-loadmore :bottom-method="loadBottom"
                   @bottom-status-change="handleBottomChange"
                   :bottom-all-loaded="allLoaded" ref="loadmore" :auto-fill="false" :bottomDropText="topDropText" :bottomPullText="topDropText">
        <!--拍品列表-->
        <product-list :productList="proHistoryList" :release="proRelease" :fixedPrice="fixedPrice" :deal="deal"></product-list>

      </mt-loadmore>
    </div>
  </div>
</template>

<script>
  import {getStatusMapByKey,getlocalStore} from '../../../assets/js/tools';
  export default {
    name: "myHistory",
    data(){
      return {
        proHistoryList:[],//当前显示拍品列表

        proRelease:null,//拍品状态：已发布
        deal:null,//拍品状态：已成交
        fixedPrice:null,//

        pageNum:1,
        pageSize:6,
        total:null,
        allLoaded: false,
        topDropText:'加载更多',
      }
    },
    created(){
      this.proRelease = getStatusMapByKey('eProductStatus').release.val;
      this.deal = getStatusMapByKey('eProductStatus').deal.val;
      this.fixedPrice = getStatusMapByKey('eProductType').fixedPrice.val;

      //获取历史记录
      this.getproHistoryList();
    },
    methods:{
      //上拉加载更多
      loadBottom() {
        if(this.pageNum < this.total) {
          this.pageNum++;
          this.getproHistoryList();
        }else {
          this.allLoaded = true;
        }
        this.$refs.loadmore.onBottomLoaded();
      },
      handleBottomChange(status){
        // console.log(status);
      },
      //获取历史记录列表
      getproHistoryList(){
        let proHistoryList = getlocalStore('proHistory');
        if(proHistoryList){
          let data = JSON.parse(proHistoryList);
          this.total =  Math.ceil(data.length / this.pageSize);
          this.proHistoryList = data.slice(0,this.pageSize*this.pageNum);
        }
      }
    }
  }
</script>

<style scoped>

</style>

